<link rel="stylesheet" href="/ceca_two/css/offerDetailsInfomation.css" />
<link rel="stylesheet" href="/ceca_two/css/supplierInfomation.css" />
<link rel="stylesheet" href="/ceca_two/css/supplier.css" />	
<link rel="stylesheet" href="/ceca_two/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" />	

<!--header-->
<!--# include virtual="/ceca_two/common/html/header.html"-->
<div class="content">
	<!--<div class="baseinfo">
		<div class="top">
			<h1>供应商信息</h1>
			<p class="supplierName"></p>
			<div class="infobox" id="infoBox">
				
			</div>
		</div>
		<div class="bot">
			<h1>经营产品类别</h1>
			<p class="supplierName"></p>
			<div class="infobox">
				<ul id="treeDemo" class="ztree"></ul>
				<ul id="treeSelect" class="ztree"></ul>
			</div>
		</div>
	</div>-->
	<div class="products">
		<div class="">
            <h1 class=""><span>经营产品类别</span></h1>
			<div class="price_box" id="price_box">
				<div class="infobox">
					<ul id="treeDemo" class="ztree"></ul>
					<ul id="treeSelect" class="ztree"></ul>
				</div>
			</div>
		</div>
	</div>
	
	<div class="products">
		<div class="">
            <h1 class=""><span>供应商其他产品</span></h1>
			<div class="product" id="product_list">
				<!--<div class="item">
					<img src="/ceca_two/img/prdt_bpic.jpg" class="itempic"/>
					<p>工字钢</p>
				</div>
				<div class="item">
					<img src="/ceca_two/img/prdt_bpic.jpg" class="itempic"/>
					<p>工字钢</p>
				</div>
				<div class="item">
					<img src="/ceca_two/img/prdt_bpic.jpg" class="itempic"/>
					<p>工字钢</p>
				</div>-->
			</div>
		</div>
	</div>
	<div class="products">
		<div class="">
            <div class="menu">
            	<ul id="tab_btn" class="clearfloat">
            		<li class="active">供应商营业执照</li>
            		<li>授权书</li>
            		<li>荣誉证书</li>
            	</ul>
            </div>
			<div class="product">
				<div class="item tab_item" style="display: block;">
					<img src="/ceca_two/img/prdt_bpic.jpg" class="itempic"/>
				</div>
				<div class="item tab_item">
					<img src="/ceca_two/img/prdt_bpic.jpg" class="itempic"/>
				</div>
				<div class="item tab_item">
					<img src="/ceca_two/img/prdt_bpic.jpg" class="itempic"/>
				</div>
			</div>
		</div>
	</div>
	<div class="products">
		<div class="">
            <h1 class=""><span>供应商信息</span></h1>
			<div class="product infoBox" id="infoBox">
				
			</div>
		</div>
	</div>
</div>
<script type="text/html" id="price_cont">
	<img src="/ceca_two/img/prdt_bpic.jpg" class="pic"/>
	<div class="infobox">
		<h2>三级盘螺</h2>
		<p>报价地区：北京市</p>
		<p>面价(t)：含税价:3850元 , 除税价:3419.7元</p>
		<p>本月交易价中值(t)：含税价:3650元 , 除税价:3119.7元</p>
		<p>增值税税率：17%</p>
		<p>运费结算方式：两票制</p>
		<p>运费说明：不含运费</p>
	</div>
</script>
<script type="text/html" id="infoCont">
	<p><label>联系人：</label><span>{{#  if(d.linkman){ }}{{d.linkman}}{{#  } }}</span></p>
	<p><label>经营模式：</label><span>{{#  if(d.manageMode){ }}{{d.manageMode}}{{#  } }}</span></p>
	<p><label>纳税人类型：</label><span>{{#  if(d.taxpayerType){ }}{{d.taxpayerType}}{{#  } }}</span></p>
	<p><label>所在地区：</label><span id="areaCity">北京市</span></p>
	<p><label>供应产品：</label><span id="productLength">XX条</span></p>
	<p><label>公司电话：</label><span>{{#  if(d.contactNumber){ }}{{d.contactNumber}}{{#  } }}</span></p>
	<p><label>邮箱：</label><span>{{#  if(d.email){ }}{{d.email}}{{#  } }}</span></p>
	<p>
		<label>产品手册：</label>
		<span>
		{{#  if(d.productManuals){ }}
			{{#  layui.each(d.productManuals, function(index, item){ }}
				<a href="{{item.url}}" title="点击下载" style="margin-right: 20px;">{{item.name}}</a>
			{{# }); }}
		{{#  } }}
		</span>
	</p>
</script>
<!--底部-->
<!--# include virtual="/ceca_two/common/html/footer.html"-->
<!--<script src="/ceca_two/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js" type="text/javascript" charset="utf-8"></script>-->
<script src="/ceca_two/common/js/area.js" type="text/javascript" charset="utf-8"></script>
<script src="/ceca_two/modules/market/base/jquery.ztree.all-3.5.js" type="text/javascript" charset="utf-8"></script>
<script src="/ceca_two/modules/market/base/jquery.ztree.exhide-3.5.js" type="text/javascript" charset="utf-8"></script>
<script>
var setting = {
	view: {
		dblClickExpand: true,
		showLine: true,
		selectedMulti: true
	},
	data: {
		simpleData: {
			enable:true,
			idKey: "categoryId",
			pIdKey: "categoryParentId",
			rootPId: "0"
		},
		key:{
			name: "categoryName",
			checked: "state"
		}
	},
	edit: {
		editNameSelectAll: true,
		drag: {
			isCopy: false,
			isMove: false
		}
	}
};
var selectSetting = {
	view: {
		dblClickExpand: true,
		showLine: true,
		selectedMulti: true
	},
	data: {
		simpleData: {
			enable:true,
			idKey: "categoryId",
			pIdKey: "categoryParentId",
			rootPId: "0"
		},
		key:{
			name: "categoryName"
		}
	},
	edit: {
		editNameSelectAll: true,
		drag: {
			isCopy: false,
			isMove: false
		}
	}
};	
	var categoryObj = {};
	var categoryBaseObj = getCategory();
	var t = $("#treeDemo");
	zTree = $.fn.zTree.init(t, setting, categoryBaseObj.allNode);
	
	initProduct(categoryBaseObj.chooseNode);
	wang.tab("#tab_btn li",".tab_item");
	
	layui.use(['Zutil','laytpl'], function() {
		var Zutil = layui.Zutil,laytpl = layui.laytpl;
		$.ajax({
			type:"post",
			url:"/guidance_service/front/supplier/get.do",
			data:{
				supplierId:Zutil.getQueryString("supplierId")
			},
			success:function(data){
				if (data.resultCode == 200) {
					$(".supplierName").html(data.data.supplierName);
					$(".tab_item img").eq(0).attr("src",data.data.businessCertificate);
					$(".tab_item img").eq(1).attr("src",data.data.certificateOfAuthorization);
					$(".tab_item img").eq(2).attr("src",data.data.certificateOfHonor);
					var cont = infoCont.innerHTML;
					data.data.productManuals=JSON.parse(data.data.productManuals);
					laytpl(cont).render(data.data, function(html){	
						$("#infoBox").html(html);
					});
					$("#areaCity").html(areaObj[data.data.areaCode.substr(0,2) + "0000"]);
					$("#productLength").html(categoryBaseObj.chooseNode.length+"条");
				} else{
					layer.msg("请求失败，请稍后重试。",{icon:2,time:2000 })
				}
			},
			error:function(){
			}
		});
	})
function initProduct(arrStr){
	$("#treeDemo").show();
	var listHtml="";
	var imgurl;
	var productObj=[];
	for (i = 0 ; i < arrStr.length ; i++) {
		productObj.push(arrStr[i].productCategoryId);
		if(arrStr[i].materialPic){
			imgurl=arrStr[i].materialPic;
		}else if(arrStr[i].specificationUrl){
			imgurl=arrStr[i].specificationUrl;
		}else if(arrStr[i].materialUrl){
			imgurl=arrStr[i].materialUrl;
		}
		listHtml+='<div class="item"><img src="'+imgurl+'" class="itempic"/><p>'+arrStr[i].categoryName+'</p></div>';
	}
	$("#product_list").html(listHtml);
	//product_list
	var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
		allNode = zTree.transformToArray(zTree.getNodes());
    
    zTree.hideNodes(allNode);
    
    for (i = 0 ; i < productObj.length ; i++) {
    	var nodeList = zTree.getNodesByParamFuzzy("categoryCode", productObj[i], null);
		nodeList = zTree.transformToArray(nodeList);
		zTree.showNode(nodeList[0]);
		findParent(zTree , nodeList[0]);
    }

    function findParent(treeObj,node){
    	treeObj.expandNode(node,true,false,false);
        var pNode = node.getParentNode();
        if(pNode != null){
        	zTree.showNode(pNode);
        	findParent(treeObj,pNode);
    	}
    }
}
function getCategory(){
	$.ajax({
	    type:"post",
	    url:"/guidance_service/front/market/category/search.do",
	    async:false,
	    success : function (result){
	    	console.log(result);
			categoryObj.allNode = result.data;
			
	    },error : function (e){
	    	layui.use(['layer'],function(){
	    	    layer.msg("请求错误,请稍后重试",{icon:2,time:2000})
	    	})
	    }
	});	
	$.ajax({
		type:"post",
		url:"/guidance_service/front/supplier/product/getProducts.do",
		async:false,
		data:{
			supplierId : wang.getQueryString("supplierId")
		},
		success:function(obj){
			categoryObj.chooseNode = obj.data;
		}
	});
	return categoryObj;
}
</script>
</body>
</html>